package com.whty.cms.filewps.common.service;

import com.qcloud.cmq.Message;

import java.util.List;

/**
 * Created by Administrator on 2019/2/27 0027.
 */
public interface CmqService {
    /**
     * 创建队列
     * @param queueName   队列名称
     * @param maxMsgHeapNum 最大堆积消息数
     * @param pollingWaitSeconds 消息接收长轮询等待时间。取值范围 0 - 30秒，默认值0
     * @param visibilityTimeout 消息可见性超时
     * @param maxMsgSize  消息最大长度
     * @param msgRetentionSeconds 消息保留周期
     * @param rewindSeconds 队列是否开启回溯消息能力
     * @throws Exception
     */
    void createQueue(String queueName, int maxMsgHeapNum, int pollingWaitSeconds, int visibilityTimeout, int maxMsgSize, int msgRetentionSeconds, int rewindSeconds) throws Exception;

    /**
     * 生产消息
     * @param queueName 队列名称
     * @param msg   消息
     * @return
     * @throws Exception
     */
    String sendMsg(String queueName, String msg) throws Exception;

    /**
     * 消费消息
     * @param queueName 队列名称
     * @param pollingWaitSeconds
     * @return
     * @throws Exception
     */
    Message receiveMessage(String queueName, int pollingWaitSeconds) throws Exception;

    /**
     * 批量消费消息
     * @param queueName
     * @param numOfMsg
     * @param pollingWaitSeconds
     * @return
     * @throws Exception
     */
    List<Message> batchreceiveMessage(String queueName, int numOfMsg, int pollingWaitSeconds) throws Exception;

    /**
     * 删除消息
     * @param queueName
     * @param receiptHandle
     * @throws Exception
     */
    void deleteMsg(String queueName, String receiptHandle) throws Exception;

    /**
     * 批量删除信息
     * @param queueName
     * @param receiptHandle
     * @throws Exception
     */
    void batchDeleteMsg(String queueName, List<String> receiptHandle) throws Exception;
}
